package com.sangmo.fts;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;

@Configuration
public class I18NConfig {
    @Value("${spring.messages.basename}")
    private String mScanBaseName;

    @Bean
    public ReloadableResourceBundleMessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        String[] names = mScanBaseName.split(",", -1);

        for (int i = 0; i < names.length; i++) {
            names[i] = "classpath:" + names[i];
        }
        messageSource.addBasenames(names);
        messageSource.setDefaultEncoding("UTF-8");
        return messageSource;
    }
}